Skip to content

fix: incorrect UTC conversion math#245

Merged
sigmachirality merged 7 commits intomainfrom
cursor/pst-utc-conversion-math-c2f4
Feb 6, 2026
Merged

fix: incorrect UTC conversion math#245
sigmachirality merged 7 commits intomainfrom
cursor/pst-utc-conversion-math-c2f4

Conversation

@sigmachirality
Copy link
Member

@sigmachirality sigmachirality commented Feb 6, 2026

Fix timezone conversion in sf nodes create command.

The previous implementation used .utc(true) which incorrectly marked local time as UTC instead of converting it, leading to incorrect UTC times being displayed (e.g., 6pm PST showing as 10am UTC instead of 2am UTC). This PR changes .utc(true) to .utc() in src/helpers/units.ts to ensure proper conversion.


Open in Cursor Open in Web

Changed .utc(true) to .utc() in selectTime function to properly convert
local time to UTC instead of keeping the same time with UTC timezone.

- 6pm PST now correctly shows as 2am UTC (not 10am UTC)
- 7pm PST now correctly shows as 3am UTC (not 11am UTC)
- Added comprehensive timezone conversion tests

The bug was caused by using .utc(true) which keeps the same local time
but marks it as UTC, instead of .utc() which actually converts the time.

Co-authored-by: Daniel Tao <danieltaox@gmail.com>
@cursor
Copy link

cursor bot commented Feb 6, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 6, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/helpers/units.ts  32% smaller
  src/helpers/format-date.ts  0% smaller

cursoragent and others added 3 commits February 6, 2026 02:28
Co-authored-by: Daniel Tao <danieltaox@gmail.com>
Changed .utc(true) to .utc() and use isSame('day') to correctly check
if a date falls on the same calendar day in both local timezone and UTC.

Previously: dayjs(date).utc(true) kept the same time digits but marked as UTC
Now: dayjs(date).utc() properly converts the time, then we compare calendar days

Example: Feb 6 6pm PST = Feb 7 2am UTC (different days, returns false)
Example: Feb 6 10am PST = Feb 6 6pm UTC (same day, returns true)

Co-authored-by: Daniel Tao <danieltaox@gmail.com>
The previous implementation used formatDate(date.utc().toDate()) which
still formatted in local timezone because JavaScript Date objects don't
carry timezone info and formatDate uses toLocaleTimeString internally.

Added formatDateAsUTC helper that formats directly using dayjs in UTC
mode. Shows "Today" only when UTC and local fall on the same calendar
day to avoid confusion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sigmachirality sigmachirality changed the title PST UTC conversion math fix: incorrect UTC conversion math Feb 6, 2026
This project uses bun, not npm.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sigmachirality sigmachirality force-pushed the cursor/pst-utc-conversion-math-c2f4 branch from 96dd715 to 88d7a38 Compare February 6, 2026 04:23
@sigmachirality sigmachirality marked this pull request as ready for review February 6, 2026 04:26
@sigmachirality sigmachirality self-assigned this Feb 6, 2026
sigmachirality and others added 2 commits February 5, 2026 20:32
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sigmachirality sigmachirality merged commit fb18921 into main Feb 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants